"""minicms URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include, url
from django.contrib import admin

from DjangoUeditor import urls as DjangoUeditor_urls
# use Django server /media/ files
from django.conf import settings

from news.views import index, column_detail, article_detail
from user.views import index as user_index, toUpdate as user_toUpdate, save as user_save, delete as user_delete, add as user_add

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^ueditor/', include('DjangoUeditor.urls')),

    # django 1.10 不在支持 url(r'^$', 'news.views.index', name='index'), 这种写法，必须使用
    #  from news.views import index
    #  url(r'^$', index, name='index'),
    # 这种写法

    # url(r'^$', 'news.views.index', name='index'),
    # url(r'^column/(?P<column_slug>[^/]+)/$', 'news.views.column_detail', name='column'),
    # url(r'^news/(?P<article_slug>[^/]+)/$', 'news.views.article_detail', name='article'),
    url(r'^$', index, name='index'),
    url(r'^column/(?P<column_slug>[^/]+)/$', column_detail, name='column'),
    url(r'^news/(?P<pk>\d+)/(?P<article_slug>[^/]+)/$', article_detail, name='article'),

    url(r'^user$', user_index, name='user_index'),
    url(r'^user/add$', user_add, name='user_add'),
    url(r'^user/toUpdate$', user_toUpdate, name='user_update'),
    url(r'^user/save$', user_save, name='user_save'),
    url(r'^user/delete$', user_delete, name='user_delete'),
]

if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(
        settings.MEDIA_URL, document_root = settings.MEDIA_ROOT
    )
